package com.yixin.hospital.entity.bo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;

@Data
@ApiModel("分页返回体")
@ToString
public class PageInfo<T> {
    @ApiModelProperty("记录")
    protected List<T> records = new ArrayList<>();
    @ApiModelProperty("总数")
    protected long total = 0;
    @ApiModelProperty("当前页")
    protected long current;
    @ApiModelProperty("每页记录数")
    protected long size;
    @ApiModelProperty("总页数")
    protected long pages;
    public PageInfo (){}

    public PageInfo(List<T> records, long total, long current, long size) {
        this.records = records;
        this.total = total;
        this.current = current;
        this.size = size;
        this.pages = total % size == 0 ? total / size : total / size + 1;
    }
}

